package com.psa.system;

import android.app.Activity;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import com.psa.dialog.SignatureDialog;
import com.psa.tool.ExitApplication;
import com.psa.tool.IGeneralEventCallback;
import com.psa.tool.SystemTool;
import com.wxw.BaseLibrary.tool.ActivityTool;
import net.duohuo.dhroid.ioc.InjectUtil;
import net.duohuo.dhroid.ioc.IocContainer;
import net.duohuo.dhroid.ioc.annotation.InjectView;

/**
 * @author david
 */
public class SignatureReviewActivity extends Activity {
    @InjectView(id = R.id.btn_back, click = "onClick")
    private Button btn_back;
    @InjectView(id = R.id.btn_next, click = "onClick")
    private Button btn_next;
    @InjectView(id = R.id.tv_head_title)
    private TextView tv_head_title;
    @InjectView(id = R.id.review_img)
    private ImageView review_img;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ActivityTool.hideTitle(this);
        ActivityTool.fullScreen(this);
        ExitApplication.getInstance().addActivity(this);
        setContentView(R.layout.signature_review_layout);
        if (getApplication() != null && IocContainer.getShare().getApplication() != null) {
            InjectUtil.inject(this);
        } else {
            return;
        }
    }

    public void onClick(View view) {
        if (view.getId() == R.id.btn_next) {
            SignatureDialog signatureDialog = new SignatureDialog(this);
            signatureDialog.setOkListener(new IGeneralEventCallback() {
                @Override
                public void finished(Object sender, String eventContent) {
                    try {
                        review_img.setImageBitmap(SystemTool.imageZoom(BitmapFactory.decodeFile(eventContent), 5.0));
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            });
            signatureDialog.show();
        } else {
            setResult(1);
            finish();
        }
    }
}
